package com.lfc.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JdkProxyInvocationHandler implements InvocationHandler {
    // 定义目标对象
    private final Object obj;

    public JdkProxyInvocationHandler(Object obj) {
        this.obj = obj;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("操作前的原生对象：" + method.getName());
        Object result = method.invoke(obj, args);
        System.out.println("调用后的操作：" + method.getName());
        return result;
    }
}
